home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / monax25 / ptotals.c < prev    next >
Text File  |  1987-10-18  |  3KB  |  121 lines

  1. /* ptotals.c - Report tool for use with STATS AX.25 monitor program.
  2.    This module is part of ptotals.exe
  3.                   
  4.    Language = Microsoft C version 4.0
  5.  
  6.  
  7.    This source is distributed freely and may be copied and
  8.    redistributed with the following provisos:
  9.    
  10.            You may not sell it, nor may you charge for making 
  11.            copies beyond the actual cost of mailing and media.
  12.                       
  13.    Written by Skip Hansen WB6YMH and Harold Price NK6K.
  14.  
  15.    Feedback is desired.
  16.  
  17.    RCP/M (213) 541-2503 300/1200/2400 baud
  18.    or via packet WB6YMH @ WB6YMH-2 or 
  19.          NK6K @ NK6K
  20.  
  21.    Modification history:
  22.  
  23.     8/10/87         NK6K: Initial release.    
  24.     ver 1.0         
  25.  
  26.    10/18/87     NK6K: First general release.
  27.    ver 1.1
  28. */
  29.  
  30.  
  31.  
  32.  
  33. #include <stdio.h>
  34.  
  35. /* ptotals - prints from total file built by total.exe */
  36. struct TOTALS {
  37.     char call[10];
  38.     unsigned long rx_tbytes;        /* total bytes */
  39.     unsigned long rx_udbytes;        /* unique data bytes */
  40.     unsigned long rx_ndbytes;        /* non-digi data bytes */
  41.     unsigned long rx_tdbytes;        /* total data bytes */
  42.     unsigned long tx_tbytes;        /* total bytes */
  43.     unsigned long tx_udbytes;        /* unique data bytes */
  44.     unsigned long tx_ndbytes;        /* non-digi data bytes */
  45.     unsigned long tx_tdbytes;        /* total data bytes */
  46. } total;
  47.  
  48. char fbuf[257];
  49. long recnum=0;
  50. main()
  51. {
  52. int tmp;
  53.     printf(
  54. "Call       TX      TX      TX   TX    RX      RX      RX   RX\n"   );
  55.     printf(
  56. "           TBytes  Ubytes  %%EFF %%Rtry TBytes  Ubytes  %%EFF %%Rtry \n\n");
  57.  
  58.     while (gets(fbuf)!=NULL) {
  59.  
  60.         if ((fbuf[0]=='Z') || (fbuf[0]=='S')) {
  61.             tmp = sscanf(fbuf+2,"%[^,],%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu",
  62.                 total.call,
  63.                 &total.rx_tbytes,
  64.                 &total.rx_udbytes,
  65.                 &total.rx_ndbytes,
  66.                 &total.rx_tdbytes,
  67.                 &total.tx_tbytes,
  68.                 &total.tx_udbytes,
  69.                 &total.tx_ndbytes,
  70.                 &total.tx_tdbytes);
  71.  
  72.  
  73.             if (tmp!=9) {
  74.                 cprintf("*** bad rec, number %lu ***\r\n",recnum); 
  75.                 break;
  76.                 }
  77.             recnum++;
  78.  
  79.             printf("%-11s%-8lu%-8lu",
  80.                 total.call,
  81.                 total.tx_tbytes,
  82.                 total.tx_udbytes);
  83.             if (total.tx_tbytes==0) printf("     ");
  84.             else printf("%-5.0f",
  85.                 ((float) total.tx_udbytes / (float) total.tx_tbytes) * 100.0);
  86.             if (total.tx_ndbytes==0) printf("      ");
  87.             else printf("%-5.0f ",
  88.                 100.0-((float) total.tx_udbytes / (float) total.tx_ndbytes) * 100.0);
  89.  
  90.  
  91.             printf("%-8lu%-8lu",
  92.                 total.rx_tbytes,
  93.                 total.rx_udbytes);
  94.             if (total.rx_tbytes==0) printf("     ");
  95.             else printf("%-5.0f",
  96.                 ((float) total.rx_udbytes / (float) total.rx_tbytes) * 100.0);
  97.             if (total.rx_ndbytes==0) printf("      ");
  98.             else printf("%-5.0f",
  99.                 100.0-((float) total.rx_udbytes / (float) total.rx_ndbytes) * 100.0);
  100.             printf("\n");
  101.  
  102.             if (fbuf[0]=='Z') {
  103.                 printf(
  104. "The following values are only for bytes sent to or received from %s.\n",total.call);
  105.                 printf(
  106. "RX means bytes received from %s, TX means bytes sent to %s\n\n\n",total.call,total.call);
  107.                 printf(
  108. "Call       TX      TX      TX   TX    RX      RX      RX   RX\n"   );
  109.                 printf(
  110. "           TBytes  Ubytes  %%EFF %%Rtry TBytes  Ubytes  %%EFF %%Rtry \n\n");
  111.  
  112.                 }
  113.  
  114.             }
  115.         }
  116. }
  117.  
  118.  
  119.  
  120.  
  121.